package javabean;
import java.sql.*;

public class DataBaseConnection{
	private final String DBDRIVER   = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; 
	private final String DBURL      = "jdbc:sqlserver://localhost:1433; DatabaseName=bookcrossing;" ;//useUnicode=true&characterEncoding=GBK
	private final String DBUSER     = "sa";
	private final String DBPASSWORD = "root";
	private Connection conn			= null;

	public DataBaseConnection(){
		try{
			Class.forName(DBDRIVER);
			this.conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
		}
		catch(Exception e){
			System.out.println("Database Connection failed: "+e);
		}
	}
	
	
	public Connection getConnection(){
		return this.conn;
	}
	

	public void close(){
		try{
			this.conn.close();
		}
		catch(Exception e){
		}
	}
}